package cn.nnb.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.nnb.dao.BasicDao.IQuery;
import cn.nnb.pojo.Order;
import cn.nnb.pojo.User;

public class OrderDao extends BasicDao {

	static {
		TABLE_NAME = "T_ORDER";
	}

	private static class InnerSingleton {
		public static OrderDao dao = new OrderDao();
	}

	private OrderDao() {

	}

	public static OrderDao getInstence() {
		return InnerSingleton.dao;
	}

	/**
	 * tong ji wan cheng de ding dan
	 * 
	 * @return
	 */
	public int getCompletedOrderAmount() {
		Map<String, String> where = new HashMap<String, String>();
		List<Order> completedOrderList = query(null, where, new IQuery() {

			public List<Order> getListFromResultSet(ResultSet resultSet)
					throws SQLException {

				List<Order> result = new ArrayList<Order>();
				Order order;
				while (resultSet.next()) {
					order = new Order();

					result.add(order);
				}
				return result;
			}

		});

		return completedOrderList.size();
	}

}
